package com.edianping.main;

import java.rmi.Naming;

/**
 * 
 * @author jszhang 从远程读取Crawler的运行状态
 * 
 */

public class RemoteClient {
	public static void main(String[] args) {
		try {
			// RMIObject.stop();
			// RMIObject.restart();
			if (args.length >= 2) {
				String url = "//"+args[0]+":8808/backend";

				IRemoteMainTask RMIObject = (IRemoteMainTask) Naming.lookup(url); // 寻得对象
				System.out.println("thread pool size: " + RMIObject.getCurrentPoolQueenSize());
				
				if (args[1].equalsIgnoreCase("restart"))
					RMIObject.restart();
				else if (args[1].equalsIgnoreCase("stop"))
					RMIObject.stop();
				else if (args[1].equalsIgnoreCase("pause"))
					RMIObject.pause();
				else if (args[1].equalsIgnoreCase("pause"))
					RMIObject.resume();
				else if (args[1].equalsIgnoreCase("status")) {
					System.out.println( RMIObject.status() );
				}
				else{
					System.out.println( "invalid argument:"+args[2] );
				}
			}
			else{
				System.out.println( "invalid argument count:"+args.length );
			}
		} catch (Exception e) {
			System.err.println("Client exception: " + e.toString());
			e.printStackTrace();
		}
	}
}
